package MaintMenu.PoAnalysis;

import java.sql.*;
import java.text.NumberFormat;

/**
 * Created with IntelliJ IDEA.
 * User: Jason
 * Date: 7/11/13
 * Time: 2:20 PM
 * To change this template use File | Settings | File Templates.
 */
public class ValueCal {

    double stkvalue=0.00D;
    public double comparePrice(double prot, double depo, double tyg_tx, double ks, double tyg_tw, double gd, double kv, double gn,int instock) {
        //reset stkvalue to "";
        stkvalue=0.00D;
//        System.out.println("stkvalue should be null :"+stkvalue);
        double bestPrice = 9999D;
        String bestCompany = "null";


        if (prot > 0.0D && prot  < bestPrice) {
            bestPrice = prot ;
            bestCompany = "prot";
            stkvalue = instock*bestPrice;         }
        if (depo > 0.0D && depo < bestPrice) {
            bestPrice = depo;
            bestCompany = "depo";
            stkvalue = instock*bestPrice;
        }
        if (tyg_tx > 0.0D && tyg_tx < bestPrice) {
            bestPrice = tyg_tx;
            bestCompany = "tyg_tx";
            stkvalue = instock*bestPrice;         }
        if (ks > 0.0D && ks < bestPrice) {
            bestPrice = ks;
            bestCompany = "ks";
            stkvalue = instock*bestPrice;         }
        if (tyg_tw > 0.0D && tyg_tw < bestPrice) {
            bestPrice = tyg_tw;
            bestCompany = "tyg_tw";
            stkvalue = instock*bestPrice;         }
        if (gd > 0.0D && gd  < bestPrice) {
            bestPrice = gd ;
            bestCompany = "gd";
            stkvalue = instock*bestPrice;         }
        if (kv > 0.0D && kv  < bestPrice) {
            bestPrice = kv ;
            bestCompany = "kv";
            stkvalue = instock*bestPrice;         }
        if (gn > 0.0D && gn  < bestPrice) {
            bestPrice = gn ;
            bestCompany = "gn";
            stkvalue = instock*bestPrice;         }
        if ( prot+depo+tyg_tx+ks+tyg_tw+gd+kv+gn==0) {
            bestPrice = 0.00 ;
//            bestCompany = "gn";
            stkvalue = 0.00D;
        }

        return stkvalue;
    }


}
